package com.yike.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 操作日志类型枚举
 **/
@Getter
@AllArgsConstructor
public enum WxPayCodeEnum {

    SYSTEMERROR("SYSTEMERROR", "接口返回错误"),
    PARAM_ERROR("PARAM_ERROR", "参数错误"),
    ORDERPAID("ORDERPAID", "订单已支付"),
    NOAUTH("NOAUTH", "商户无权限"),
    AUTHCODEEXPIRE("AUTHCODEEXPIRE", "二维码已过期"),
    NOTENOUGH("NOTENOUGH", "余额不足"),
    NOTSUPORTCARD("NOTSUPORTCARD", "不支持卡类型"),
    ORDERCLOSED("ORDERCLOSED", "订单已关闭"),
    ORDERREVERSED("ORDERREVERSED", "订单已撤销"),
    BANKERROR("BANKERROR", "银行系统异常"),
    USERPAYING("USERPAYING", "用户支付中"),
    AUTH_CODE_ERROR("AUTH_CODE_ERROR", "付款码参数错误"),
    AUTH_CODE_INVALID("AUTH_CODE_INVALID", "付款码检验错误"),
    XML_FORMAT_ERROR("XML_FORMAT_ERROR", "XML格式错误"),
    REQUIRE_POST_METHOD("REQUIRE_POST_METHOD", "请使用post方法"),
    SIGNERROR("SIGNERROR", "签名错误"),
    LACK_PARAMS("LACK_PARAMS", "缺少参数"),
    NOT_UTF8("NOT_UTF8", "编码格式错误"),
    BUYER_MISMATCH("BUYER_MISMATCH", "支付账号错误"),
    APPID_NOT_EXIST("APPID_NOT_EXIST", "APPID不存在"),
    MCHID_NOT_EXIST("MCHID_NOT_EXIST", "MCHID不存在"),
    OUT_TRADE_NO_USED("OUT_TRADE_NO_USED", "商户订单号重复"),
    APPID_MCHID_NOT_MATCH("APPID_MCHID_NOT_MATCH", "appid和mch_id不匹配"),
    INVALID_REQUEST("INVALID_REQUEST", "无效请求"),
    TRADE_ERROR("TRADE_ERROR", "交易错误"),
    Null(null, "支付失败");

    private String code;
    private String desc;

    public static String getDesc(String code) {
        return Arrays.stream(WxPayCodeEnum.values()).filter(a -> a.getCode().equals(code)).findAny().get().getDesc();
    }

}
